home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / ps40sdk / examples / selection / shape / shapeuiwin.c < prev   
Encoding:
C/C++ Source or Header  |  1996-08-11  |  4.8 KB  |  178 lines

  1. /*
  2.     File: ShapeUIWin.c
  3.  
  4.     Copyright 1991-96 by Adobe Systems, Inc.
  5.  
  6.     C source file for Windows specific code for Selection example.
  7. */
  8.  
  9. #include "Shape.h"
  10. #include "WinDialogUtils.h"
  11.  
  12. /*****************************************************************************/
  13.  
  14. BOOL WINAPI SelectionProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam); // Win32 Change
  15. short ShowAlert (short stringID);
  16.  
  17. /*****************************************************************************/
  18.  
  19. void DoAbout (GPtr globals)
  20. {
  21.     ShowAbout((AboutRecordPtr)gStuff, hDllInstance, AboutID);
  22. }
  23.  
  24. /****************************************************************************/
  25. /* Example for ShowAlert() function which takes a string ID as parameter    */
  26. /* and displays a message box                                               */
  27. /****************************************************************************/
  28.  
  29. short ShowAlert (short stringID)
  30. {
  31.     char szMessage[256];
  32.     char szTitle[128];
  33.  
  34.     LoadString(hDllInstance, stringID, szMessage, sizeof szMessage);
  35.     LoadString(hDllInstance, 2, szTitle, sizeof szTitle);
  36.     return  ( MessageBox(NULL, szMessage, szTitle, MB_OK | MB_ICONHAND) );
  37.  
  38. }
  39.  
  40. /*****************************************************************************/
  41.  
  42. BOOL WINAPI SelectionProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) // Win32 Change
  43. {
  44.     int        idd;    // WIN32 Change
  45.     static GPtr globals=NULL;          /* need to be static */    
  46.     
  47.     switch  (wMsg)
  48.     {
  49.  
  50.         case  WM_INITDIALOG:
  51.  
  52.             /* set up globals    */
  53.             globals = (GPtr) lParam;
  54.             
  55.             CenterDialog(hDlg); // CenterWindow(hDlg, CW_BOTH);
  56.             
  57.             SetRadioGroupState(hDlg,
  58.                                kFirstItem,
  59.                                kLastItem,
  60.                                kFirstItem + gWhatShape);
  61.             SetRadioGroupState(hDlg,
  62.                                kCreateRadio1,
  63.                                kCreateRadioLast,
  64.                                kCreateRadio1 + gCreate);
  65.             /* fall into WM_PAINT */
  66.         case WM_PAINT:
  67.             return FALSE;
  68.             break;
  69.  
  70.         case  WM_COMMAND:
  71.               idd = COMMANDID (wParam);              // WIN32 Change
  72.             if (idd >= kFirstItem && idd <= kLastItem)
  73.                 SetRadioGroupState(hDlg, kFirstItem, kLastItem, wParam);
  74.             else if (idd >= kCreateRadio1 && idd <= kCreateRadioLast)
  75.                 SetRadioGroupState(hDlg, kCreateRadio1, kCreateRadioLast, wParam);
  76.             else
  77.             {
  78.                 switch  (idd)
  79.                 {
  80.                     case ok:
  81.                         gWhatShape = GetRadioGroupState(hDlg, kFirstItem, kLastItem)
  82.                                      - kFirstItem;
  83.                         gCreate = GetRadioGroupState(hDlg, kCreateRadio1, kCreateRadioLast)
  84.                                   - kCreateRadio1;
  85.                         EndDialog(hDlg, idd);
  86.                         break;
  87.                     case cancel:
  88.                         gResult = userCanceledErr;
  89.                         EndDialog(hDlg, idd);          // WIN32 change
  90.                         break;
  91.                     default:
  92.                         return FALSE;
  93.                         break;
  94.                 }
  95.             }
  96.             break;
  97.         default:
  98.             return FALSE;
  99.             break;
  100.     }
  101.     return TRUE;
  102. }
  103.  
  104. /*****************************************************************************/
  105. Boolean DoParameters (GPtr globals)
  106. {
  107.  
  108.     int                nResult = noErr;
  109.     PlatformData    *platform;
  110.     
  111.     platform = ((SelectionRecordPtr) gStuff)->platformData;
  112.  
  113.     /* Query the user for parameters. */
  114.  
  115.     nResult = DialogBoxParam(hDllInstance,
  116.                        (LPSTR)"SELECTIONPARAM",
  117.                        (HWND)platform->hwnd,
  118.                        (FARPROC)SelectionProc,
  119.                         (LPARAM)globals);
  120.  
  121.     return (nResult == true); // could be -1
  122. }
  123.  
  124. /*****************************************************************************/
  125.  
  126. /* Initialization and termination code for window's dlls. */
  127.  
  128. // Win32 Change
  129. #ifdef WIN32
  130.  
  131. // Every 32-Bit DLL has an entry point DLLInit
  132.  
  133. BOOL APIENTRY DLLInit(HANDLE hInstance, DWORD fdwReason, LPVOID lpReserved)
  134. {
  135.  
  136.     if (fdwReason == DLL_PROCESS_ATTACH)
  137.         hDllInstance = hInstance;
  138.  
  139.     return TRUE;   // Indicate that the DLL was initialized successfully.
  140. }
  141.  
  142. #else
  143. /* ------------------------------------------------
  144.  *   Code from Borland's window's dll example code.
  145.  * ------------------------------------------------
  146.  */
  147. #if defined(__BORLANDC__)
  148. // Turn off warning: Parameter '' is never used; effects next function only
  149. #pragma argsused
  150. #endif
  151.  
  152. // Every DLL has an entry point LibMain and an exit point WEP.
  153. int FAR PASCAL LibMain( HANDLE hInstance, WORD wDataSegment,
  154.                                    WORD wHeapSize, LPSTR lpszCmdLine )
  155. {
  156.     // Required when using Zortech; causes blink to include startup code
  157.     extern __acrtused_dll;
  158.  
  159.     // The startup code for the DLL initializes the local heap (if there is one)
  160.     // with a call to LocalInit which locks the data segment.
  161.     if ( wHeapSize != 0 )
  162.         UnlockData( 0 );
  163.  
  164.     hDllInstance = hInstance;
  165.     return 1;   // Indicate that the DLL was initialized successfully.
  166. }
  167.  
  168. int FAR PASCAL WEP(int nParam)
  169. {
  170.     switch  (nParam) {
  171.       case  WEP_SYSTEM_EXIT: // System shutdown in progress
  172.       case  WEP_FREE_DLL   : // DLL use count is 0
  173.       default :              // Undefined;  ignore
  174.             return  1;
  175.     }
  176. }
  177. #endif
  178.